<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>药品目录</title>
    <style type="text/css">
        td{
            height: 25px;
            width: 100px;
            border: #3a8ee6 1px solid;

        }
        input{
            height: 21px;
        }
    </style>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../../js/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="../../js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../../js/02/drugb/yeshu1.js"></script>
    <script type="text/javascript" src="../../js/02/drugb/cengci.js"></script>
    <script type="text/javascript" src="../../js/02/quanxuan.js"></script>
    <script type="text/javascript" src="../../js/02/sales%20return/num02.js"></script>
    <script type="text/javascript" src="../../js/02/sales%20return/addd.js"></script>
    <script type="text/javascript">
        //查询供货商
        $(function () {
            gets()
            $.ajax({
                url: '/myspringboot/purchasement/findAllghs',
                type: 'post',
                dataType: "json",
                success: function (result){
                    var dclist=result.data;
                    var dcid = document.getElementById("dcid");
                    var dcid1 = document.getElementById("dcid1");
                    dcid.innerHTML = "<option value='0'>全部</option>";
                    for (var i = 0; i < dclist.length; i++) {
                        var opt = document.createElement("option");
                        opt.innerText = dclist[i].surName;
                        opt.setAttribute("value", dclist[i].surId)
                        dcid.appendChild(opt)
                    }
                }
            })

            $.ajax({
                url: '/myspringboot/purchasement/findyaopin',
                type: 'post',
                dataType: "json",
                success: function (result){
                    var dclist=result.data;
                    var dcid = document.getElementById("dcid2");
                    dcid.innerHTML = "<option value='0'>全部</option>";
                    for (var i = 0; i < dclist.length; i++) {
                        var opt = document.createElement("option");
                        opt.innerText = dclist[i].diName;
                        opt.setAttribute("value", dclist[i].diId)
                        dcid.appendChild(opt)
                    }
                }
            })


        })
        function adddd() {
            var aaa=$("#dcid2").val();
            alert(aaa)
            var v = window.location.href;
            var v1 = v.substring(v.lastIndexOf("?") + 1, v.length);
            alert(v1)

            /**
             * 向采购单中间表添加药品id
             */
            $.ajax({
                url: '/myspringboot/purchasement/addyaopinid1',
                type: 'post',
                dataType: "json",
                data: {
                    id:aaa,
                    v:v1
                },

                success: function (result) {
                    if (result.msg=="yes"){
                        alert("添加成功")
                        window.location.reload();
                    } else {
                        alert("添加失败")
                    }

                }
            })
        }

        /**
         * 退货下的删除选项
         */

        function adf1() {
            var id_array = new Array();
            $('input[name=chec]:checked').each(function () {
                id_array.push($(this).val());//向数组中添加元素
            });  //获取界面复选框的所有值
            var id = id_array.join(',');//把复选框的值以数组形式存放
            alert(id)
            var v = window.location.href;
            var v1 = v.substring(v.lastIndexOf("?") + 1, v.length);
            alert(v1)
            //console.log(id)
            $.ajax({
                url: "/myspringboot/purchase/finddelect1",
                data: {id: id,v:v1},
                type: "post",
                dataType: "json",
                success: function (result) {
                    if (result.msg=="成功") {
                        alert("删除成功");
                        window.location.reload()//刷新当前页面.
                    }else {
                        alert("删除失败")
                    }
                }
            });

        }
    </script>
</head>
<body>
<div>
    <table class="" style="border: 1px solid #999;border-collapse:collapse">
        <tr>
           <h1>退货单添加药品</h1>
        </tr>
        <tr>
            <td>药品流水号：</td>
            <td><input id="dinumber" name="dinumber" type="text" value=""></td>
            <td></td>
            <td>通用名：</td>
            <td><input id="cname" name="cname" type="text" value=""></td>
            <td></td>
        </tr>
        <tr>
            <td>剂型：</td>
            <td><input id="jixing" name="jixing" type="text" value=""></td>
            <td></td>
            <td>规格：</td>
            <td><input id="guige" name="guige" type="text" value=""></td>
            <td></td>
        </tr>
        <tr>
            <td>单位：</td>
            <td><input id="danwei" name="danwei" type="text" value=""></td>
            <td></td>
            <td>转换系数：</td>
            <td><input id="cc" name="cc" type="text" value=""></td>
            <td></td>
        </tr>
        <tr>
            <td>生产企业：</td>
            <td><input name="qiye" id="qiye" type="text" value=""></td>
            <td></td>
            <td>商品名：</td>
            <td><input name="shangpin" id="shangpin" type="text" value=""></td>
            <td></td>
        </tr>
        <tr>
            <td>价格范围：</td>
            <td><input id="lefPprice" style="width: 65px" type="text" value="">至<input id="rightPrice" style="width: 65px" type="text" value=""></td>
            <td></td>
            <td>质量层次：</td>
            <td>
                <select id="cengci" style=" height: 25px; width: 160px;">
                <option value="">全部</option>

            </select>
            </td>
            <td></td>
        </tr>
        <tr>
            <td>供货商：</td>
            <td>
                <select id="dcid" style=" height: 25px; width: 160px;">
                    <option value="">请选择</option>
                </select>
            </td>
            <td></td>
            <td style="width: 120px">药品交易状态:</td>
            <td>
                <select id="state" name="state" style=" height: 25px; width: 160px;">
                    <option value="">全部</option>
                    <option value="">正常</option>
                    <option value="">不正常</option>

                </select>
            </td>
            <td></td>
        </tr>


    </table>
    <td>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="reset"  onclick="gets()">查询</button><br>


    </td>
    <table>
        <tr>
            <button data-toggle="modal" data-target="#yaopin">添加</button>
            <button type="button" onclick="adf1()">删除</button>
            <button type="button" onclick="haha()">保存退货量</button>
        </tr>
        <tr>
            <td>序号</td>
            <td><input type="checkbox" id="checkbox1" onclick="selectAll(this)">选择</td>
            <td>流水号</td>
            <td>通用名</td>
            <td>商品名称</td>
            <td>剂型</td>
            <td>规格</td>
            <td>单位</td>
            <td>转换系数</td>
            <td>中标价</td>
            <td>交易价</td>
            <!--<td>采购量</td>
            <td>总金额</td>
            <td>入库量</td>-->
            <td>退货量</td>
            <td>退货原因</td>
        </tr>
        <tbody class="a">
        </tbody>
    </table>

</div>
<div class="im-page" id="impage">
    <tr>
        <td><button id='first'>首页</button></td>
        <td><button id='before'>上一页</button></td>
        <td>第<span id="pnum"></span>页</td>
        <td>共<span id="ptotal"></span>页</td>
        <td><button  id='next'>下一页</button></td>
        <td><button id='last'>尾页</button></td>
    </tr>
</div>

<!--修改数据-->
<div class="modal fade" id="yaopin" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalyaopin">
                    退货单添加
                </h4>
            </div>
            <div class="modal-body">
                <table>
                    <tr>
                        <td>选择药品：</td>
                        <td>
                            <select id="dcid2" style=" height: 50px; width: 400px;">
                                <option value="">请选择</option>
                            </select>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="modal-footer">
                <button id="adddd" type="button" class="btn btn-default" data-dismiss="modal" onclick="adddd()">保存
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>
</html>
